﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Survival;
using Survival.Animals;
using Survival.Plants;
using Survival.Services;
using Survival.World;
using System.Linq;
using System.Text;

namespace Survival.Components
{
    class WorldQuery : IWorldQuery
    {
        private PlantManager plantManager;
        private AnimalManager animalManager;

        public WorldQuery(AnimalManager animalManager, PlantManager plantManager)
        {
            this.plantManager = plantManager;
            this.animalManager = animalManager;
        }

        public List<PlantData> GetVisiblePlants(IPhysical asker,float sightDistance)
        {
            List<PlantData> plantDataList = new List<PlantData>();
            foreach (Plant plant in plantManager.PlantList)
            {
                float distanceSquared = Vector2.DistanceSquared(asker.Position, plant.Position);
                if (distanceSquared < sightDistance * sightDistance)
                {
                    plantDataList.Add(new PlantData(plant,distanceSquared));
                }
            }

            return plantDataList;
        }
    }
}
